package com.kalian.web;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kalian.pojo.User;
import com.kalian.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("user")
public class UserController {
    @Autowired
    UserService userService;

    @GetMapping("page")
    public Page<User> page(int pageNum, int pageSize, @RequestParam(defaultValue = "") String input){
        return userService.page(pageNum,pageSize,input);
    }

    @PostMapping("add")
    public void save(@RequestBody User user){
        userService.save(user);
    }

    @GetMapping("del")
    public void del( int id){
        userService.del(id);
    }

    @GetMapping("findName")
    public List<User> findName(String name){
        return userService.findName(name);
    }
}
